package com.jagochan.module.business.controller;


import com.jagochan.common.result.ResultUtils;
import com.jagochan.common.result.ResultVo;
import com.jagochan.module.business.pojo.po.Adsense;
import com.jagochan.module.business.service.AdsenseService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.NotNull;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Validated
@Tag(name = "广告轮播")
@RestController
@RequestMapping("/community/adsense")
public class AdsenseController {

    @Resource
    private AdsenseService adsenseService;

    @Operation(summary = "查询广告轮播列表")
    @GetMapping("/list")
    public ResultVo<List<Adsense>> page(@Parameter(description = "广告轮播类型(my-个人中心)", example = "my")
                                        @NotNull(message = "广告轮播类型不能为空") String type) {
        return ResultUtils.success("查询成功", adsenseService.lambdaQuery().eq(Adsense::getType, type).list());
    }

}
